
package br.com.ltn4java.transformation;

import java.util.ArrayList;
import java.util.List;

/**
 * Create in July, 14, 2011
 * Criado em 14 de julho de 2011<br/>
 * Qualquer sugestão envia um e-mail para mim miguellima@aljug.com.br <br/>
 * Any suggestions send an e-mail me miguellima@aljug.com.br <br/>
 * http://aljug.blogspot.com - ALJUG - Alagoas Java User Group <br/>
 * http://miguellimapj.blogspot.com - Miguel´s blog </br>
 * @author Miguel
 * @version ltn4java 0.3 <br/>
 */

public class LetterForNumber {

    /**
     * 
     */
    public LetterForNumber() {
    }
  /**
     *
     * @param FullWord
     * Metodo para pegar valor de cada letra da string passada pelo usuário <br/>
     * Method to get value of each letter of the string passed by the user.<br/>
     * @return Inteiros
     * List of Integer extracted of the FullWord <br/>
     * Inteiros é uma lista de array extraida a partir da String passada pelo
     * usuário <br/>
     * Example: FullWord = Alagoas Java User Group <br/>
    *  So the result will be <b>1 12 1 7 15 1 19 10 1 22 1 21 19 5 18 7 18 15 21 16</b>
     */


    public List takeLetterByletter(String FullWord) {
        int Counter = FullWord.length();
        List Inteiros = new ArrayList();
        String FullWordUpper = FullWord.toUpperCase();
        FullWordUpper = FullWordUpper.replaceAll("Ã", "A");
        FullWordUpper = FullWordUpper.replaceAll("Â", "A");
        FullWordUpper = FullWordUpper.replaceAll(" ", "");
        System.out.println(FullWordUpper);
        char[] letters = FullWordUpper.toCharArray();
        int[] output = new int[letters.length];

        for (int i = 0; i < letters.length; i++) {

            output[i] = (int) letters[i];
            int inicial = 65;
            if (output[i] == 65) {
                output[i] = 1;
            } else {
                if (output[i] != 65) {
                    output[i] = (output[i] - inicial) + 1;
                }
            }

            Inteiros.add(output[i]);
            System.out.print(" " + output[i]);

        }
        return Inteiros;
    }


/**
 *
 * @param letter
 * is a letter that the user move to transform into a whole number <br/>
 * @param NewLetter
 * is a variable that receives the converted value of char to String<br/>
 * letter é um caractere que o usuário quer transformar em um número inteiro<br/>
 * NewLetter é uma variavel que recebe o valor convertido de char para String<br/>
 * @return letter_caracter
 *  é o auxiliar para o receber o número e retornar para o usuário. <br/>
 * letter_caracter is the assistant to receive and return the number to the user<br/>
 * Example: char letter = 'A' <br/>
 * So teh result will be <b>1<b/>
 */
      public int letterForNumberInteger(char letter) {


        String NewLetter = String.valueOf(letter);
        NewLetter = NewLetter.toUpperCase();
        int letter_caracter = 0;

        if ((NewLetter.equalsIgnoreCase("A"))) {
            letter_caracter = 1;
            System.out.println(letter_caracter);
        }
        if ((NewLetter.equals("B"))) {
            letter_caracter = 2;
            System.out.println(letter_caracter);
        }

        if ((NewLetter.equals("C"))) {
            letter_caracter = 3;
            System.out.println(letter_caracter);
        }
        if ((NewLetter.equals("D"))) {
            letter_caracter = 4;
            System.out.println(letter_caracter);
        }
        if ((NewLetter.equals("D"))) {
            letter_caracter = 5;
            System.out.println(letter_caracter);
        }
        if ((NewLetter.equals("F"))) {
            letter_caracter = 6;
            System.out.println(letter_caracter);
        }
        if ((NewLetter.equals("G"))) {
            letter_caracter = 7;
            System.out.println(letter_caracter);
        }
        if ((NewLetter.equals("H"))) {
            letter_caracter = 8;
            System.out.println(letter_caracter);
        }
        if ((NewLetter.equals("I"))) {
            letter_caracter = 9;
            System.out.println(letter_caracter);
        }
        if ((NewLetter.equals("J"))) {
            letter_caracter = 10;
            System.out.println(letter_caracter);
        }
        if ((NewLetter.equals("K"))) {
            letter_caracter = 11;
            System.out.println(letter_caracter);
        }
        if ((NewLetter.equals("L"))) {
            letter_caracter = 12;
            System.out.println(letter_caracter);
        }

        if ((NewLetter.equals("M"))) {
            letter_caracter = 13;
            System.out.println(letter_caracter);
        }
        if ((NewLetter.equals("N"))) {
            letter_caracter = 14;
            System.out.println(letter_caracter);
        }
        if ((NewLetter.equals("O"))) {
            letter_caracter = 15;
            System.out.println(letter_caracter);
        }
        if ((NewLetter.equals("P"))) {
            letter_caracter = 16;
            System.out.println(letter_caracter);
        }
        if ((NewLetter.equals("Q"))) {
            letter_caracter = 17;
            System.out.println(letter_caracter);
        }
        if ((NewLetter.equals("R"))) {
            letter_caracter = 18;
            System.out.println(letter_caracter);
        }
        if ((NewLetter.equals("S"))) {
            letter_caracter = 19;
            System.out.println(letter_caracter);
        }
        if ((NewLetter.equals("T"))) {
            letter_caracter = 20;
            System.out.println(letter_caracter);
        }
        if ((NewLetter.equals("U"))) {
            letter_caracter = 21;
            System.out.println(letter_caracter);
        }
        if ((NewLetter.equals("V"))) {
            letter_caracter = 22;
            System.out.println(letter_caracter);
        }
        if ((NewLetter.equals("W"))) {
            letter_caracter = 23;
            System.out.println(letter_caracter);
        }
        if ((NewLetter.equals("X"))) {
            letter_caracter = 24;
            System.out.println(letter_caracter);
        }
        if ((NewLetter.equalsIgnoreCase("Y"))) {
            letter_caracter = 25;
            System.out.println(letter_caracter);
        }
        if ((NewLetter.equalsIgnoreCase("Z"))) {
            letter_caracter = 26;
            System.out.println(letter_caracter);
        }


        return letter_caracter;
    }


}
